package com.bw.day03.adapter

import android.graphics.Color
import android.widget.LinearLayout
import android.widget.TextView
import com.bw.base.net.entity.CateEntityItem
import com.bw.day03.R
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class OneAdapter: BaseQuickAdapter<CateEntityItem, BaseViewHolder>(R.layout.item_one) {
    var selectId=515
    override fun convert(
        holder: BaseViewHolder,
        item: CateEntityItem
    ) {
        holder.setText(R.id.one_tv,item.name)
        if (item.id==selectId){
            holder.getView<TextView>(R.id.one_tv).setTextColor(Color.BLUE)
            holder.getView<LinearLayout>(R.id.ll_one).setBackgroundResource(R.drawable.bg_cade_one)

        }else{
            holder.getView<TextView>(R.id.one_tv).setTextColor(Color.BLACK)
            holder.getView<LinearLayout>(R.id.ll_one
            ).background=null
        }
    }
    fun setId(id: Int){
        selectId=id
        notifyDataSetChanged()
    }
}